home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
tpb4_src.zip
/
SYSOP1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1988-09-13
|
9KB
|
303 lines
{ TPBoard 4.2 Copyright (c) 1987,88 by Jon Schneider & Rick Petersen
Portions Copyright (c) 1986,87 by Steve Fox and Les Archambault
Last modified :: 6-12-88 3:58 pm
}
{$R-} {Range checking off}
{$B-} {Boolean complete evaluation off}
{$S-} {Stack checking off}
{$I+} {I/O checking on}
{$N-} {No numeric coprocessor}
Unit Sysop1;
Interface
Uses
TPCrt, Dos, Globals, TAccess, Core1, Misc,
Core2, TPSTRING, Dirs, MsgMove, MsgRead;
procedure hide_release(name : DosFileName;
status : record_status;
Dirspec : StrPr);
function get_section_name(mode : Char) : DosFileName;
procedure rebuild_index;
procedure toggle_printer;
procedure print_messages;
{==========================================================================}
Implementation
procedure hide_release(name : DosFileName;
status : record_status;
Dirspec : StrPr);
{ Hide or release file }
var
attributes : Word;
begin
SetSect(Dirspec);
Assign(temp_file, name);
if status = public then
attributes := 0 {make visable}
else
attributes := Hidden+SysFile; {set System and Hidden bits}
SetFAttr(temp_file, attributes);
if (user_rec.access >= 250) or (not remote_copy) then
begin
if DosError = 2 then
WriteLn(Com, name, ' not found.');
if DosError = 3 then
WriteLn(Com, 'path: ', Dirspec, ' not found.');
if DosError = 5 then
WriteLn(Com, 'Access denied by DOS.');
end;
end;
function get_section_name(mode : Char) : DosFileName;
{ for file area sections}
var
This : SectPtr;
line_count,
conf_num : Integer;
work : DosFileName;
begin
abort := False;
repeat
This := SectBase;
WriteLn(Com);
work := prompt('Section name ', 12, 'ES?M');
if (work = ' ') and (mode <> 'L') then
begin
work := SectReq; { default to current value }
WriteLn(Com, 'Defaulting to: ', SectReq);
end;
if work = '?' then
begin
line_count := 2;
WriteLn(Com, 'Available file areas:');
WriteLn(Com);
while (not brk) and (This <> nil) do
begin
conf_num := This^.SectConf;
if (user_rec.access >= This^.SectAccs) or (test_bit(user_rec.conf_flags,
conf_num)) then
begin
Write(Com, pad(This^.SectName, 14));
if (mode = 'D') or (mode = 'L') then
WriteLn(Com, This^.SectDesc)
else
WriteLn(Com);
end;
This := This^.next;
if user_rec.lines <> 99 then
begin
Inc(line_count);
if line_count mod user_rec.lines = 0 then
pause;
end;
end;
WriteLn(Com);
end;
This := SectBase;
while (This <> nil) and (This^.SectName <> work) do
This := This^.next;
until (work = This^.SectName) or (brk) or (not Online);
if work = This^.SectName then
get_section_name := work
else
get_section_name := '';
end;
procedure rebuild_index;
{ Rebuild the user index file from the data file. In addition, this routine
will recover the data file from certain types of damage. }
var
previous_rec,
count_used,
count_unused : Integer;
i : LongInt;
key : StrName;
temp_user_rec : user_list;
temp : file;
begin
SetSect(HomName);
WriteLn(Com, 'Rebuilding user index file.');
WriteLn(Com, 'User data file in record order:');
CloseIndex(IdxF);
Assign(temp, user_indx+ext);
Erase(temp);
MakeIndex(IdxF, user_indx+ext, len_ln+len_fn, 0);
previous_rec := -1;
count_used := 0;
count_unused := 0;
with temp_user_rec do
begin
for i := 1 to Pred(FileLen(DatF)) do
begin
GetRec(DatF, i, temp_user_rec);
if used = 0 then
begin
key := pad(ln, len_ln)+pad(fn, len_fn);
AddKey(IdxF, i, key);
if OK then
begin
Inc(count_used);
WriteLn(Com, i:4, ' ', used:4, ' ', fn, ' ', ln)
end
else
begin
used := previous_rec; { Can't use DeleteRec since }
previous_rec := i; { we're playing with pointers }
PutRec(DatF, i, temp_user_rec);
Inc(count_unused);
WriteLn(Com, i:4, ' ', used:4, ' Duplicate record deleted')
end
end
else
begin
used := previous_rec;
previous_rec := i;
PutRec(DatF, i, temp_user_rec);
Inc(count_unused);
WriteLn(Com, i:4, ' ', used:4, ' Free record')
end
end
end;
GetRec(DatF, 0, temp_user_rec);
DatF.FirstFree := previous_rec;
DatF.NumberFree := count_unused;
PutRec(DatF, 0, temp_user_rec);
FlushFile(DatF);
FlushIndex(IdxF);
WriteLn(Com);
WriteLn(Com, FileLen(DatF), ' records, ', UsedRecs(DatF), ' users in file.')
end;
procedure toggle_printer;
{ Turn printer on and off }
begin
if printer_copy then
printer_copy := False
else
printer_copy := ask('Turn on printer', 'N');
Write(Com, 'Printer o');
if printer_copy then
WriteLn(Com, 'n.')
else
WriteLn(Com, 'ff.')
end;
procedure print_messages;
{ Print the message file }
var
i, j,
first_line,
last_line : Integer;
cur_date : Real;
Fr_fn : FirstName;
Fr_ln : LastName;
t : tad_array;
Str : StrTAD;
err : Boolean;
begin
abort := False;
Str := prompt('Date to start listing [mm/dd/yy]', 8, 'E');
if ch <> ETX then
begin
GetTAD(t);
if Length(Str) >= 2 then
t[4] := strint(Copy(Str, 1, 2)); {month}
if Length(Str) >= 5 then
t[3] := strint(Copy(Str, 4, 2)); {day}
if Length(Str) >= 8 then
t[5] := strint(Copy(Str, 7, 2)); {year}
cur_date := greg_to_jul(t[3], t[4], t[5]);
GetTAD(t);
Str := FormTAD(t);
WriteLn(Com, 'Message file as of: ', Str);
if audit_on then
begin
SetSect(AudName);
WriteLn(AuditFile, FF, 'Message file as of: ', Str);
SetSect(HomName);
end;
i := 1;
{$I-}
Seek(summ_file, 1); {$I+}
err := (IoResult <> 0);
while (not err) and (not brk) and Online and (not EoF(summ_file)) do
begin
{$I-}
Read(summ_file, summ_rec) {$I+} ;
err := (IoResult <> 0);
if (not err) and (greg_to_jul(summ_rec.date[3], summ_rec.date[4], summ_rec.date[5]
) >= cur_date) then
begin
WriteLn(Com);
if audit_on then
begin
SetSect(AudName);
WriteLn(AuditFile);
SetSect(HomName);
end;
mesg_header_list(i, first_line, last_line, Fr_fn, Fr_ln);
{$I-}
Seek(mesg_file, first_line); {$I+}
err := (IoResult <> 0);
if (not err) then
begin
for J := 1 to last_line do
begin
{$I-}
Read(mesg_file, mesg_rec); {$I+}
err := (IoResult <> 0);
if (not err) then
WriteLn(Com, mesg_rec);
if audit_on and (not err) then
begin
SetSect(AudName);
WriteLn(AuditFile, mesg_rec);
SetSect(HomName);
end;
end;
end;
end;
Inc(i);
end;
end;
end;
end. { of SYSOP1.PAS}